package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmLoginDto;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {
    @Resource
    private WmMaterialService wmMaterialService;
    // multipartFile要与前端的文件name一致

    /**
     * 图片上传
     * @param multipartFile
     * @return
     */
    @PostMapping("/upload_picture")
    public ResponseResult uploadImage(MultipartFile multipartFile){
        return wmMaterialService.uploadImage(multipartFile);
    }

    /**
     * 获取图片素材列表
     * @param dto
     * @return
     */

    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDto dto){
        return  wmMaterialService.findList(dto);

    }
}
